import axios from 'axios'
const baseURL='/tk_blog/';
//const baseURL='http://mrzhuo.top/tk_blog/'
const indexContent = (page=1) => {
	return axios.post(baseURL+'index.php/Index/index/p/'+page).then((res) => {
		if(!res.status){
			return res;
		}
		return res.data;
	})

}
const articleContent = (id='') => {
	return axios.get(baseURL+'a/'+id).then((res) => {
		if(!res.status){
			return res;
		}
		return res.data;
	})

}

const searchContent = (id,isTid) => {
	var url;
	if(isTid){
		url=baseURL+'st/'+id;
	}else{
		url=baseURL+'Search?k='+id;
	}
	return axios.get(url).then((res) => {
		if(!res.status){
			return res;
		}
		return res.data;
	})
	

}


const tagsContent = () => {
	return axios.get(baseURL+'Tags').then((res) => {
		if(!res.status){
			return res;
		}
		return res.data;
	})

}

const titleDatasContent = () => {
	return axios.get(baseURL+'Article/titleDatas').then((res) => {
		if(!res.status){
			return res;
		}
		return res.data;
	})

}
const commentsContent = (aid) => {
	return axios.get(baseURL+'Comments/getCommentsData',{
		params:{
			'aid':aid
		}

	}).then((res) => {
		if(!res.status){
			return ;
		}
		return res.data;
		
	})

}
const sendCommentsContent = (content,aid) => {
	return axios.get(baseURL+'Comments/saveComments',{
		params:{
			'content':content,
			'aid':aid
		}
	}).then((res) => {
	
		return res.data;
	})

}
export default {
	indexContents: indexContent,
	articleContents:articleContent,
	searchContent:searchContent,
	tagsContent:tagsContent(),
	titleDatasContent:titleDatasContent(),
	commentsContent:commentsContent,
	sendCommentsContent:sendCommentsContent
}